package marina;

import java.util.Scanner;

public class J10SungJuk_ {
	//return을 이용한 메서드
	public static void main(String[] args){
		//Scanner sc = new Scanner(System.in); => 불순물은 따로 빼세요.
		String name[] = new String[2];
		int kor[] = new int[2]; 
		int eng[] = new int[2]; 
		int mat[] = new int[2]; 
		int tot;
		double avg;
		char grd;
		
		name[1] = inputName();
		kor[1] = inputKor(makeScanner());
		eng[1] = inputEng();
		mat[1] = inputMat(makeScanner());
		tot =  getTotal(kor,eng,mat);
		avg = getAverage(tot);
		grd = getGrade(avg);
		
		System.out.println(name[1]);
		System.out.println(kor[1]);
		System.out.println(eng[1]);
		System.out.println(mat[1]);
		System.out.println(tot);
		System.out.println(avg);
		System.out.println(grd);

	}//main

	//주의: Scanner 클래스를 이용해서 입력 처리하고 close()를 하게 되면 다시 Scanner 생성 불가
	private static int inputMat(Scanner sc) {
		System.out.println("수학 점수는?");
		int d = sc.nextInt();
		closeScanner(sc);
		return d;
	}

	private static int inputEng() {
		System.out.println("영어 점수는?");
		int c = makeScanner().nextInt();
		return c;
	}

	private static int inputKor(Scanner sc) {
		System.out.println("국어 점수는?");
		int b = sc.nextInt();
		return b;
	}

	private static String inputName() {
		System.out.println("이름은?");
		String a = makeScanner().next();	//좀 더 세련된 표현. 은폐,엄폐에 있어서 좀 더 좋은 구조라 할 수 있음.
		return a;
	}

	private static char getGrade(double avg) {
		char grd;
		switch ((int) avg / 10) { 
		case 10:
			grd = '수';
			break;
		case 9:
			grd = '수';
			break;
		case 8:
			grd = '우';
			break;
		case 7:
			grd = '미';
			break;
		case 6:
			grd = '양';
			break;
		default:
			grd = '가';
		}
		return grd;
	}

	private static double getAverage(int tot) {
		int avg = tot / 3;
		return avg;
	}

	private static int getTotal(int kor[], int eng[], int mat[]) {
		int tot = kor[1] + eng[1] + mat[1];
		return tot;
	}
	// scanner 생성
	public static Scanner makeScanner(){ //참조 형식의 변수도 가능하다는 거~
		Scanner sc = new Scanner(System.in);
		return sc;
	}
	// scanner 소멸
	public static void closeScanner(Scanner sc){
		sc.close();
	}
}
